home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13588 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: news.microsoft.com!news
  2. From: a-cnadc@microsoft.com (Dann Corbit)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Q: free() function
  5. Date: 8 Apr 1996 23:01:50 GMT
  6. Organization: Microsoft Corporation
  7. Message-ID: <4kc5su$u9c@news.microsoft.com>
  8. References: <4k9ai7$rck@tibalt.supernet.ab.ca>
  9. NNTP-Posting-Host: 157.57.171.202
  10. Mime-Version: 1.0
  11. X-Newsreader: WinVN 0.93.14
  12.  
  13. In article <4k9ai7$rck@tibalt.supernet.ab.ca>, lts@news.supernet.ab.ca says...
  14. >
  15. >When dynamically allocating memory for a series of strings and storing 
  16. >the addresses in a char pointer array, can all the allocated memory be 
  17. >freed simply using "free(array)" or does "free(array[x])" have to be 
  18. >executed for each pointer in the array.
  19. >
  20. >I think the latter would be correct but I'm not 100% sure, please comment.
  21. >
  22. >-lts
  23. Depends on how the allocation was performed.  If calloc() was used, one
  24. free() statment will do it.  If malloc() was repeatedly called, you need 
  25. one free() for each malloc().  Also if the array itsself were allocated
  26. this will require a call to free() also.
  27. -- 
  28. The opinions expressed in this message are my own personal views
  29. and do not reflect the official views of Microsoft Corporation.
  30. In fact, I'm just a subcontractor, not an employee, so pull in your claws.
  31.  
  32.